﻿//-----------------------------------------------------------------------------
//<filedescription file="ArrayBuilder.TreeListPicker.cs" company="Microsoft">
//  <copyright>
//     Copyright © Microsoft Corporation.  All rights reserved.
//     ***  DESIGNATED SAMPLE CODE (per the included software license terms) ***
//      THIS CODE SAMPLE IS MADE AVAILABLE TO YOU WITHOUT WARRANTY OF ANY KIND
//      AND CONFERS NO RIGHTS ON YOU WHATSOEVER EXCEPT THE RIGHT TO REVIEW IT
//      SOLELY AS A REFERENCE.  THE ENTIRE RISK OF USE OR RESULTS FROM USE OF
//      THIS CODE SAMPLE REMAINS WITH YOU.
//  </copyright>
//  <purpose>
//     A dialog within the Array Builder UI framework that allows the user
//     to select an object from a list of similar objects currently displayed in
//     the treeview.
//
//  </purpose>
//  <notes>
//  </notes>
//</filedescription>
//-----------------------------------------------------------------------------

using System;
using System.Windows.Forms;
using System.Globalization;
using Microsoft.ConfigurationManagement.IntegrationDevelopmentKit;

namespace Microsoft.ConfigurationManagement.OemDeployment.ArrayBuilder
{
    /// <summary>
    /// 
    /// </summary>
    public partial class TreeListPickerDialog : Form
    {

        #region Properties

        /// <summary>
        /// 
        /// </summary>
        public TreeNodeCollection TreeContents
        {
            get { return treeView1.Nodes; }
            set
            {
                for (int i = 0; i < value.Count; i++)
                {
                    treeView1.Nodes.Add(value[i]);
                }
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public TreeNode SelectedNode
        {
            get
            {
                if (treeView1.SelectedNode != null)
                {
                    return treeView1.SelectedNode;
                }
                else
                {
                    return null;
                }
            }
        }



        #endregion

        #region Constructor

        /// <summary>
        /// 
        /// </summary>
        public TreeListPickerDialog()
        {
            InitializeComponent();
            this.TopMost = true;
        }


        #endregion
        
        #region Event Handlers

        private void buttonOK_Click(object sender, EventArgs e)
        {
            
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;

            this.Close();
        }

        #endregion

        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            buttonOK.Enabled = true;
        }
    }
}
